package com.chenl.provider.config;

import com.chenl.provider.DEMOS.日志相关.全链路日志以及Spring线程池装饰器的使用.TokenInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Order(0)
//@Component
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    private static final String[] EXCLUDE_PATH = {
            "/",
            "/white_list",
            "/favicon.ico",
            "/actuator/**",
            "/login/getToken",
            "/login/getUser",
            "/login/user/updateAndAdd",
            "/login/getUser",
            "/init/*",
            "/initAdb/*",
            "/data/search",
            "/login/getCode",
            "/companyAppInfo/findList",
            "/company/findListWithAppInfoList",
            "/companyAppInfo/api/create",
            "/channelType",
            "/channel",
            "/game",
            "/gameChannel",
            "/data/searchData",
            "/dataClean/*",
            "/menu/registerMenu",
            "/companyAppInfo/generatePublicEvent",
            "/reBuildKudu/*"
    };
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATH);  // 指定不拦截的连接;
        //.excludePathPatterns("/**");  // 放开所有请求
        // 拦截器配置
    }

    //无需加入容器
//    @Bean
//    public HandlerInterceptor getTokenInterceptor() {
//        return new TokenInterceptor();//添加TraceId拦截器
//    }
}
